<% target_url = 
    case attributes[:type]
      when "blog"
        "blog_url"
      when "photos"
        "photos_by_date_url"
    end
%>

<div class="generic_section archives collapsible collapsed" collapse_name="archives">
  <div class="top">
    <div class="collapsible-toggle">
      Archives
    </div>
  </div>
  <div class="main" id="bar-archives-list">
    <table>
    <% @archive.sort.each do |year_value| %>
      <tr class="year">
        <td class="date"><span><%= link_to(year_value[0], self.send(target_url, {:year => year_value[0], :month => nil})) %></span></td>
        <td class="count"><%= year_value[1]["total"] %></td>
      </tr>
      <% year_value[1]["months"].sort.each do |month_value| %>
      <tr class="month">
        <td class="date"><span><%= link_to(month_value[0], self.send(target_url, {:year => year_value[0], :month => month_value[0]})) %></span></td>
        <td class="count"><%= month_value[1] %></td>
      </tr>
      <% end %>
    <% end %>
    <% if attributes[:type] == "blog" %>
      <tr>
        <td class="blog_search_input" colspan="2">
          <% form_tag(blog_search_url, :method => 'get') do %>
            <%= text_field_tag(
                  "q", 
                  params[:q] ? h(params[:q]) : "Search", 
                  :id => 'blog_search_input',
                  :class => "default dormant",
                  :maxlength => "40" ) %>
          <% end %>
        </td>
      </tr>
    <% end %>
    </table>
  </div>
  <div class="bottom"></div>
</div>